<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report name" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="696e23a5-2605-4436-8f96-a69bea3826b6">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="sdate" class="java.lang.String"/>
	<parameter name="fdate" class="java.lang.String"/>
	<parameter name="sd" class="java.util.Date"/>
	<parameter name="fd" class="java.util.Date"/>
	<parameter name="user" class="java.lang.String"/>
	<parameter name="user_id" class="java.lang.Long"/>
	<queryString language="SQL">
		<![CDATA[SELECT
     (SELECT count(*)
        FROM
             `clients` c JOIN `clients_authorization` ca ON c.`clients_authorization_id` = ca.`id`
        WHERE
            c.state_in<>0 AND   c.`stand_time` BETWEEN '$P!{sdate} 00:00:00'  AND '$P!{fdate} 23:59:59' AND c.`clients_authorization_id` IS NOT NULL AND c.`user_id`=$P!{user_id}) as all_count,
      ca.`id` AS clientid,
     c.`id` AS idd,
     DATE_FORMAT(c.`stand_time`, '%d.%m.%Y %H:%i') AS stand_time,
     (SELECT sum(s.`client_wait_period`) FROM `clients` c JOIN `statistic` s ON c.`id` = s.`client_id` WHERE   c.state_in<>0 AND   idd=s.`client_id` AND c.`stand_time` BETWEEN '$P!{sdate} 00:00:00'  AND '$P!{fdate} 23:59:59' AND c.`clients_authorization_id` IS NOT NULL AND c.`user_id`=$P!{user_id}) AS wait_period,
     ca.`surname` AS surname,
     ca.`name` AS name,
     c.`service_prefix` AS prefix,
      c.`number` AS number
FROM
     `clients` c JOIN `clients_authorization` ca ON c.`clients_authorization_id` = ca.`id`
WHERE
    c.state_in<>0 AND   c.`stand_time` BETWEEN '$P!{sdate} 00:00:00'  AND '$P!{fdate} 23:59:59' AND c.`clients_authorization_id` IS NOT NULL AND c.`user_id`=$P!{user_id}
GROUP BY ca.`id`
ORDER BY c.`stand_time`]]>
	</queryString>
	<field name="surname" class="java.lang.String"/>
	<field name="all_count" class="java.lang.Integer"/>
	<field name="clientid" class="java.lang.Long"/>
	<field name="name" class="java.lang.String"/>
	<field name="stand_time" class="java.lang.String"/>
	<field name="wait_period" class="java.lang.String"/>
	<field name="prefix" class="java.lang.String"/>
	<field name="number" class="java.lang.String"/>
	<variable name="all_count" class="java.lang.Integer" calculation="Count">
		<variableExpression><![CDATA[$F{all_count}]]></variableExpression>
		<initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>
	</variable>
	<variable name="N" class="java.lang.Integer" calculation="Count">
		<variableExpression><![CDATA[$F{clientid}]]></variableExpression>
		<initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>
	</variable>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="91">
			<line>
				<reportElement uuid="1113fcb1-9234-4124-a0f0-b5ba41b41fcb" x="0" y="8" width="555" height="1"/>
			</line>
			<line>
				<reportElement uuid="aed994f1-4274-4a54-9606-ed695055658c" positionType="FixRelativeToBottom" x="1" y="86" width="555" height="1"/>
			</line>
			<staticText>
				<reportElement uuid="4ba234e3-6337-40a8-87cb-15db5c090c6b" x="1" y="9" width="551" height="26"/>
				<textElement textAlignment="Center">
					<font size="18" isBold="true" isStrikeThrough="false" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Отчет по авторизованным персонам за период]]></text>
			</staticText>
			<textField pattern="">
				<reportElement uuid="f760abac-42ce-4512-b456-b8fd5c4572be" x="1" y="35" width="551" height="24"/>
				<textElement textAlignment="Center">
					<font fontName="SansSerif" size="18" isBold="true" isUnderline="false" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["с даты " + (new java.text.SimpleDateFormat("dd.MM.yyyy")).format($P{sd}) + " по дату " + (new java.text.SimpleDateFormat("dd.MM.yyyy")).format($P{fd})]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="88abfafb-4306-4e3f-8ef2-0f386df919bc" x="1" y="59" width="551" height="24"/>
				<textElement textAlignment="Center">
					<font fontName="SansSerif" size="18" isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["для пользователя \"" + $P{user} +"\""]]></textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band height="13" splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="44" splitType="Stretch">
			<staticText>
				<reportElement uuid="50ecebc4-8097-43da-a67d-562de89505cf" mode="Opaque" x="1" y="12" width="113" height="30" backcolor="#CCCCFF"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="koi8-r" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Время]]></text>
			</staticText>
			<staticText>
				<reportElement uuid="d46ade36-cb4e-4f2b-a4d3-c99dcb94bd3a" mode="Opaque" x="114" y="12" width="56" height="30" backcolor="#CCCCCC"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="koi8-r" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Ожидание (мин)]]></text>
			</staticText>
			<staticText>
				<reportElement uuid="970836b2-a837-44de-be1e-166b321ec5e3" mode="Opaque" x="170" y="12" width="126" height="30" backcolor="#CCCCFF"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="koi8-r" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Документ]]></text>
			</staticText>
			<staticText>
				<reportElement uuid="2c996dab-1cd7-447d-99c0-383b072a2be6" mode="Opaque" x="296" y="12" width="54" height="30" backcolor="#CCCCCC"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="koi8-r" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Номер]]></text>
			</staticText>
			<staticText>
				<reportElement uuid="e987be57-9685-47ec-ba27-e9ff7237d64f" mode="Opaque" x="350" y="12" width="205" height="30" backcolor="#CCCCFF"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="koi8-r" isPdfEmbedded="true"/>
				</textElement>
				<text><![CDATA[Клиент]]></text>
			</staticText>
			<line>
				<reportElement uuid="4503abcb-cb7b-40b9-bd5e-7c10222ff807" x="0" y="11" width="555" height="1"/>
			</line>
			<line>
				<reportElement uuid="d3f1f72d-4599-4b4c-af84-bd52e3e285a7" x="0" y="43" width="555" height="1"/>
			</line>
		</band>
	</columnHeader>
	<detail>
		<band height="21" splitType="Stretch">
			<line>
				<reportElement uuid="2b7d693e-c348-474c-92fc-fdc626214b5e" x="0" y="20" width="555" height="1"/>
			</line>
			<textField>
				<reportElement uuid="f44aacd8-30a7-4894-afb8-84dde4eb53f0" mode="Transparent" x="350" y="1" width="205" height="18"/>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{surname}+" "+$F{name}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="5790fd7e-3de4-48d8-8bd2-a360af0cf0f0" mode="Transparent" x="1" y="1" width="113" height="18"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{stand_time}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="d240d2ad-446e-4c06-9d0a-72c53f55ebf7" mode="Transparent" x="170" y="1" width="126" height="18"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[""+$F{clientid}+""]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="9f52d67a-56fe-49e3-86eb-9826d2366074" mode="Opaque" x="114" y="1" width="56" height="18" backcolor="#CCCCCC"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[""+$F{wait_period}+""]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="4a21ac99-4cb3-46e8-8918-0c550906d47a" mode="Opaque" x="296" y="1" width="54" height="18" backcolor="#CCCCCC"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$F{prefix}+$F{number}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="45" splitType="Stretch">
			<textField>
				<reportElement uuid="fcbd2823-a57e-4a9e-abe2-1642a9c7c577" x="0" y="0" width="555" height="20"/>
				<textElement textAlignment="Center">
					<font size="14" isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["Общее количество клиентов за период: "+$V{all_count}]]></textFieldExpression>
			</textField>
		</band>
	</columnFooter>
	<pageFooter>
		<band height="41" splitType="Stretch">
			<textField evaluationTime="Report" pattern="" isBlankWhenNull="false">
				<reportElement uuid="93b4cbae-070d-4ac6-bddb-6033a8501ac7" key="textField" x="526" y="12" width="36" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font fontName="SansSerif" size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<textField pattern="" isBlankWhenNull="false">
				<reportElement uuid="fff940cb-4622-449a-9a0e-698818aa5b5c" key="textField" x="306" y="12" width="216" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right">
					<font fontName="SansSerif" size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA["Страница " + $V{PAGE_NUMBER} + " из "]]></textFieldExpression>
			</textField>
			<textField pattern="" isBlankWhenNull="false">
				<reportElement uuid="8b476fdb-773d-4269-a8a6-58f29467b717" key="textField" x="11" y="12" width="209" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font fontName="SansSerif" size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[new Date()]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<summary>
		<band height="17" splitType="Stretch"/>
	</summary>
</jasperReport>
